package com.zm.dao.impl;

import com.zm.dao.IUserDao;
import com.zm.domain.User;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.util.List;

/**
 * 实现类
 */
public class UserDaoImpl implements IUserDao {
    private SqlSessionFactory factory;

    public UserDaoImpl(SqlSessionFactory factory) {
        this.factory = factory;
    }

    @Override
    public List<User> findAll() {
        //1、使用工厂创建对象
        SqlSession session=factory.openSession();
        //2、使用session执行查询方法             ******这里是重点需要全限定类名+id来定位sql语句
        List<User> users=session.selectList("com.zm.dao.IUserDao.findAll");
        session.close();
        return users;
    }
}
